package cn.wolfcode.luowowo.website.advice;

import cn.wolfcode.luowowo.common.exception.LogicException;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

@ControllerAdvice
public class CommonExceptionHandler {

    @ExceptionHandler(LogicException.class)
    @ResponseBody
    public Object LogicExp(Exception e) throws IOException{
        e.printStackTrace();
        return  new AjaxResult(false,e.getMessage());
    }
    @ExceptionHandler(RuntimeException.class )
    @ResponseBody Object runTimeExp(Exception e) throws IOException{
        e.printStackTrace();
        return new AjaxResult(false,"系统繁忙,请稍后");
    }
}
